import org.junit.Assert;
import org.junit.Test;

import java.util.concurrent.ThreadLocalRandom;

public class testException {
    @Test
    public void sumTest() throws Exception {
        //求和
        int numberA = ThreadLocalRandom.current().nextInt(0, 100);
        int numberB = ThreadLocalRandom.current().nextInt(0, 100);
        int sum = calculate.sum(numberA, numberB);
        //int sum = Sum.sum(1000, 13);
        Assert.assertEquals(numberB + numberA, sum);
    }

    @Test
    public void differTest() throws Exception {
        //求和
        int numberA = ThreadLocalRandom.current().nextInt(0, 100);
        int numberB = ThreadLocalRandom.current().nextInt(0, 100);
        int differ = calculate.differ(numberA, numberB);
//        //1/0本来有异常，运行不了，但是trycatch包裹之后，可以使程序继续运行。
//        try {
//            int b = 1/0;
//        } catch (Exception e) {
//            //throw new RuntimeException(e);
//        }
//        //
        Assert.assertEquals(numberA - numberB, differ);
    }
}
